#include <iostream>
#include "ostream"
#include "string"


class MyInteger {
    friend std::ostream &operator<<(std::ostream &cout, MyInteger &myInteger);

private:
    int num = 0;

public:
    // 重载先++，就是自增运算符
    MyInteger &operator++() {
        num++;
        return *this;
    }

    // 重载后++，就是自增运算符
    // int代表占位参数，可以用于区分前置和后置递增
    MyInteger operator++(int) {
        //先 记录当时结果
        MyInteger temp = *this;

        //后 递增
        this->num++;

        // 最后将记录的结构做返回操作
        return temp;
    }

    int getNum() const;

};

// 左移运算符
std::ostream &operator<<(std::ostream &cout, MyInteger &myInteger) {

    return cout << myInteger.num << std::endl;;
}

void test01() {
    MyInteger myInteger{};
//    const MyInteger &integer3 = myInteger.operator++(1);

    const MyInteger &integer = myInteger++;
    const MyInteger &integer1 = myInteger++;
    const MyInteger &integer2 = myInteger++;

    std::cout << integer2.getNum() << std::endl;
    std::cout << myInteger.getNum() << std::endl;
}

int MyInteger::getNum() const {
    return num;
}


int main() {
    test01();
    return 0;
}

